#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <stdbool.h>

struct TreeNode {
    int val;
    struct TreeNode* left;
    struct TreeNode* right;
    
};

bool isSametree(struct TreeNode* root1, struct TreeNode* root2)
{
    if (root1 == NULL && root2 == NULL)
        return true;
    if (root1 == NULL || root2 == NULL)
        return false;
    if (root1->val == root2->val)
    {
        return isSametree(root1->left, root2->left) && isSametree(root1->right, root2->right);
    }
    else
        return false;
}

bool isSubtree(struct TreeNode* root, struct TreeNode* subRoot) {
    if (subRoot == NULL)
        return true;
    if (root == NULL)
        return false;
    if (!isSametree(root, subRoot))
    {
        return isSubtree(root->left, subRoot) || isSubtree(root->right, subRoot);
    }
    else
        return true;

}